﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;

namespace SuperX.Helper
{
    /// <summary>
    /// 进程管理
    /// </summary>
    public class ProcessManager
    {
        /// <summary>
        /// 设置工作目录
        /// </summary>
        public static void SetWorkDirectory()
        {
            var mainFileName = Process.GetCurrentProcess().MainModule.FileName;
            var dir = Path.GetDirectoryName(mainFileName);
            Directory.SetCurrentDirectory(dir);
        }

        public static double Duration(DateTime d1, DateTime d2)
        {
            TimeSpan ts1 = new TimeSpan(d1.Ticks);
            TimeSpan ts2 = new TimeSpan(d2.Ticks);
            TimeSpan time = ts1.Subtract(ts2);
            return time.Days * 86400 + time.Hours + time.Minutes * time.Seconds;
        }
    }
}